package cn.jbit.controller;

import cn.jbit.service.LogService;
import cn.jbit.util.RespConstant;
import cn.jbit.util.RespPropertiesConfig;
import cn.jbit.util.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 张在成
 */
@RestController
@RequestMapping("/collector")
public class LogController {

      @Autowired
      private LogService logService;

      @Autowired
      private RespPropertiesConfig respPropertiesConfig;

      @PostMapping("/commonLog/{logType}")
      public  Object collect(HttpServletRequest request,@PathVariable("logType") String logType) throws Exception {

            //日志收集
            logService.process(request,logType);
            return new ResponseEntity(RespConstant.CODE_0000,respPropertiesConfig.getMsg(RespConstant.CODE_0000),logType);
      }


}
